 package org.arabidopsis.ahocorasick;





 class SparseEdgeList
   implements EdgeList
 {
   private Cons head = null;


   public State get(byte b) {
     Cons c = this.head;
     while (c != null) {
       if (c.b == b)
         return c.s;
       c = c.next;
     }
     return null;
   }

   public void put(byte b, State s) {
     this.head = new Cons(b, s, this.head);
   }

   public byte[] keys() {
     int length = 0;
     Cons c = this.head;
     while (c != null) {
       length++;
       c = c.next;
     }
     byte[] result = new byte[length];
     c = this.head;
     int j = 0;
     while (c != null) {
       result[j] = c.b;
       j++;
       c = c.next;
     }
     return result;
   }

   private static class Cons
   {
     public Cons(byte b, State s, Cons next) {
       this.b = b;
       this.s = s;
       this.next = next;
     }

     byte b;
     State s;
     Cons next;
   }
 }